//
//  YSDownloadListernVC.m
//  YSDownLoadManager_Example
//
//  Created by Kyson on 2018/11/29.
//  Copyright © 2018 kysonyangs. All rights reserved.
//

#import "YSDownloadListernVC.h"
#import "XMGSementBarVC.h"
#import "YSDownLoadAllTVC.h"
#import "YSDownLoadLoadingTVC.h"
#import "YSDownLoadSuccessTVC.h"

@interface YSDownloadListernVC ()

@property (nonatomic, weak) XMGSementBarVC *segmentBarVC;

@end

@implementation YSDownloadListernVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    self.segmentBarVC.segmentBar.frame = CGRectMake(0, 0, 300, 40);
    self.navigationItem.titleView = self.segmentBarVC.segmentBar;
    
    self.segmentBarVC.view.frame = CGRectMake(0, 60, self.view.frame.size.width, self.view.frame.size.height - 60);
    [self.view addSubview:self.segmentBarVC.view];
    
    YSDownLoadAllTVC *vc1 = [[YSDownLoadAllTVC alloc] init];
    vc1.view.backgroundColor = [UIColor brownColor];
    YSDownLoadAllTVC *vc2 = [[YSDownLoadAllTVC alloc] init];
    vc2.view.backgroundColor = [UIColor blueColor];
    YSDownLoadAllTVC *vc3 = [[YSDownLoadAllTVC alloc] init];
    vc3.view.backgroundColor = [UIColor cyanColor];
    [self.segmentBarVC setUpWithItems:@[@"全部", @"下载中", @"已完成"] childVCs:@[vc1, vc2, vc3]];
    
    [self.segmentBarVC.segmentBar updateWithConfig:^(XMGSegmentBarConfig *config) {
        config.segmentBarBackColor = [UIColor clearColor];
    }];
}

#pragma mark - 懒加载
- (XMGSementBarVC *)segmentBarVC {
    if (!_segmentBarVC) {
        XMGSementBarVC *segmentBarVC = [[XMGSementBarVC alloc] init];
        [self addChildViewController:segmentBarVC];
        _segmentBarVC = segmentBarVC;
    }
    return _segmentBarVC;
}

@end
